package objectThree;

public class studentTest {
    public static void main(String[] args) {
        Student[] student=new Student[20];
        for (int i = 0; i < student.length; i++) {
            student[i]=new Student();
            student[i].number=i+1;
            student[i].state=(int)(Math.random()*6+1);
            student[i].score=(int)(Math.random()*101);
        }
        for (int i = 0; i < student.length; i++) {
            if(student[i].state==3){
                Student stu=student[i];
                System.out.println(stu.number+"\t"+"学生成绩："+stu.score+"分"+"\t"+"学生年级："+stu.state);
            }
        }
        System.out.println("****************************************************************");
        for (int i = 0; i < student.length; i++) {
            Student stu=student[i];
            System.out.println(stu.number+"\t"+"学生成绩："+stu.score+"分"+"\t"+"学生年级："+stu.state);
        }
        System.out.println("****************************************************************");
        for (int i = 0; i < student.length - 1; i++) {
            for (int j = 0; j < student.length - 1 - i; j++) {
                if(student[j].score>student[j+1].score){
                    Student temp=student[j];
                    student[j]=student[j+1];
                    student[j+1]=temp;
                }
            }
        }
        System.out.println("****************************************************************");
        for (int i = 0; i < student.length; i++) {
            Student stu=student[i];
            System.out.println(stu.number+"\t"+"学生成绩："+stu.score+"分"+"\t"+"学生年级："+stu.state);
        }
    }
}
